<?php
/*
 * Session variables:
 * $_SESSION['database'] [string] = database name of the current tutorial centre
 * $_SESSION['type'] [string] = user type of the logged in user
 * $_SESSION['authorised'] [boolean] = whether or not the current user is logged in
 * $_SESSION['user'] [string] = the username/ email of the logged in user
 * $_POST['audibility'] [int]
 * $_POST['manner_of_teaching'] [int]
 * $_POST['materials_used'] [int]
 * $_POST['preparedness'] [int]
 * $_POST['subject_mastery'] [int]
 */
session_start();

if(isset($_SESSION['authorised']) && $_SESSION['authorised'] == true) {
	if(isset($_SESSION['type'])) {
		if($_SESSION['type'] == 'administrator') {
			header('Location: admin_index.php');
			exit();
		}
		elseif($_SESSION['type'] == 'student') {
			if (isset($_POST['submit']) && $_POST['submit'] == true) {
				include('connection.inc');
				$teacher_id = $_POST['tutor'];
				$audibility = $_POST['audibility'];
				$manner_of_teaching = $_POST['manner_of_teaching'];
				$materials_used = $_POST['materials_used'];
				$preparedness = $_POST['preparedness'];
				$subject_mastery = $_POST['subject_mastery'];
				$sql = "INSERT INTO tutor_evaluations (teacher_id, audibility, manner_of_teaching, subject_mastery, materials_used, preparedness) values ($teacher_id, $audibility, $manner_of_teaching, $subject_mastery, $materials_used, $preparedness) returning *;";
				$result = pg_query($sql);
				$evaluation_id = pg_fetch_result($result, 0, 'evaluation_id');
				$_SESSION['evaluation_id'] = $evaluation_id;
				?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Home</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
<style>
.nav {
	width: 210px;
	height: auto;
	border: thin solid #09C;
	margin-left: 10px;
	text-align: center;
}

.mainline {
	width: 712px;
	height: auto;
	text-align: center;
}
</style>
</head>
<body bgcolor="#FFFFFF">
	<center>

		<div id="wrapper">
			<div id="header">
				<h1></h1>
			</div>

			<div id="header2">
				<h3></h3>
			</div>

			<div id="nav">
				<?php include 'student_navigation.php';?>
			</div>

			<div id="mainline">
				<h4>Tutor Evaluation - 2 of 2</h4>
				<div id="body">
					<h3>Comments</h3>
					<form action="student_evaluatetutor3.php" method="post">
					<textarea rows="15" cols="60" name="comments" id="comments"></textarea><br /><br />
					<input name="submit" type="submit" value="Submit" align="left" />
					</form>
				</div>
			</div>

			<br class="clearfloat"> <br />

			<div id="footer">
				<p align="center">
					Tutorial Business Manager: info@tbms.com <br />Credits/Engineers:
					Aquino, Chloebelle; Dela Cruz, Roy Erwin; Maliwanag, Ranyel Bryan;
					Manzano, Audrey Ann; Ng, Sheila Regine<br /> <br />copyright 2011
				</p>
			</div>
		</div>
	</center>
</body>
</html>
				<?php
			}
			else {
				header('Location: student_evaluatetutor.php');
			}
		}
		elseif($_SESSION['type'] == 'tutor') {
			header('Location: tutor_index.php');
			exit();
		}
		elseif($_SESSION['type'] == 'parent') {
			header('Location: parent_index.php');
			exit();
		}
	}
}
else {
	header('Location: index.php');
}
?>